package uestc.bitman.edxapp.mainui;

import uestc.bitman.edxapp.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @category The adapter of drawer listView
 */
public class DrawerAdapter extends BaseAdapter {

	// private ListView listView;

	private Context mContext;

	public DrawerAdapter(Context context) {
		mContext = context;
		mDisplayNames = context.getResources().getStringArray(
				R.array.array_drawer);
	}

	private final int mIconsId[] = { R.drawable.home,R.drawable.home, R.drawable.download,
			R.drawable.download, R.drawable.logout, R.drawable.about };

	private String mDisplayNames[];

	@Override
	public int getCount() {
		return mDisplayNames.length;
	}

	@Override
	public String getItem(int position) {
		return mDisplayNames[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		if (view == null) {
			view = LayoutInflater.from(mContext).inflate(R.layout.drawer_item,
					null, false);
		}
		TextView textView = (TextView) view.findViewById(R.id.drawer_text_view);
		textView.setText(mDisplayNames[position]);
		ImageView imageView = (ImageView) view
				.findViewById(R.id.drawer_image_view);
		imageView.setImageResource(mIconsId[position]);
		return view;
	}
}
